#include <map>
#include "Simplex.h"
#include "Triangle.h"
#include "TopologicalModel.h"


std::map<Simplex, Triangle*, SimplexLess> * ComputeAdjacency (LinkArray<Triangle> tris)
{
	std::map<Simplex, Triangle*, SimplexLess> *tri_adj = new
		std::map<Simplex,Triangle*, SimplexLess> ;

	for (int i = tris.Size () ; i--; )
	{
		for (int j = 3; j--;)
		{
			Simplex edge = tris[i]->GetSet(). GetSubset (j);

			map<Simplex, Triangle*, SimplexLess>
				::const_iterator k (tri_adj -> find  (edge));

			if (k == tri_adj->end ())
				(*tri_adj)[edge] = tris[i];
			else
				/* oh shit. */
				assert( false);
		}
	}

	return tri_adj;
}
